using UnityEngine;

namespace MLTimeline
{
    [System.Serializable]
    public abstract class EventClip : IClip
    {
        public float time;
        private int _frame;
        public int StartFrame => _frame;
        public int EndFrame => _frame;

        public void Initialize(Timeline timelineData)
        {
            //根据插入时间计算当前所在帧
            _frame = Mathf.CeilToInt(timelineData.frameRate * time);
            OnInitialize(timelineData);
        }

        protected virtual void OnInitialize(Timeline timelineData)
        {
        }

        public virtual void Enter() { }
        public virtual void Exit() { }
        public virtual void Evaluate(int frame, float progress, float frameRate) { }
    }
}